﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Web.UI.WebControls;
using Ue.Infrastructure.RepositoryFramework;
using Ue.Infrastructure.Web.UI;
using Ue.Qcdz.Domain;
using Ue.Qcdz.Domain.Products;

namespace Ue.Qcdz.UI.Controls
{
    public class ProductView : SkinnedGridView
    {
        private string skinFileName = "/Themes/zh-cn/Skins/Globals_Index_NewsProductBox.ascx";
        public int Num { get; set; }
        public EntityState State { get; set; }
        

        #region Overrides of SkinnedControl

        protected override string GetSkinFileName()
        {
            return skinFileName;
        }

        #endregion

        #region Overrides of SkinnedGridView

        protected override void GridViewDataBind(object sender, EventArgs args)
        {
            IProductRepository repository = RepositoryFactory.GetRepository<IProductRepository, Product>();
            IList<Product> products = repository.FindBy(Num, State);
            Repeater repeater = sender as Repeater;
            repeater.DataSource = products;
            repeater.DataBind();
            this.RecordCount = products.Count;
        }

        #endregion
    }
}
